import $ from 'jquery'

const body = window.top.document.body
export const ldConfirm = {
    /**
    * @param title 标题提示文字
    * @param content 描述
    */
    show(para) {
        const confirmStr = `<div class="ld-black ld-black-confirm">
                                <div class="ld-confirm">
                                    <div class="ld-messagebox-header">
                                        <span>${para.title || "提示"}</span>
                                        <i class="iconfont icon-close"></i>
                                    </div>
                                    <div class="ld-messagebox-content">
                                        <i class="iconfont icon-jinggao"></i>
                                        <span>${para.content || ""}</span>
                                    </div>
                                    <div class="ld-messagebox-btns">
                                        <button class="ld-default catch" size="small">取消</button>
                                        <button class="ld-primary then" size="small">确定</button>
                                    </div>
                                </div>
                            </div>`
        $(body).append(confirmStr)
    },
    catch() {

    },
    then() {

    }
}


$(document).on("click", ".ld-black-confirm button", function () {
    if ($(this).hasClass("catch"))
        ldConfirm.catch()
    else
        ldConfirm.then()
    $(body).find(".ld-black-confirm").remove()
})

$(document).on("click", ".ld-black-confirm .icon-close", function () {
    ldConfirm.catch()
    $(body).find(".ld-black-confirm").remove()
})